#ifndef BUSCAN_H_INCLUDED
#define BUSCAN_H_INCLUDED

#include <MCP23X08.h>
#include <Wire.h>
#include <Spi.h>
#include <MCP2510.h>  // The CAN interface device
#include <Canutil.h>  // The CAN interface utilities


class Bus_can
{
  public:
    Bus_can(int test);//constructor

    //in setup
    void start();

    void setAcceptanceFilter(unsigned int stdID, unsigned long extID, uint8_t extended, uint8_t filter);
    void setAcceptanceMask(unsigned int stdID, unsigned long extID, uint8_t buffer);

    void startFinished();

    uint8_t whichOpMode();

    //in program
    void sendMsg(uint8_t *tosend);
    void readMsg();
    void somethingReceived();

    int getIsInt();
    void setInt();
    void resetInt();

    void setMsgID(uint16_t id);
    uint8_t getData(int i);


  private:
    MCP2510  can_dev; // defines pb0 (arduino pin8) as the _CS pin for MCP2510
    Canutil  canutil;
    MCP23008 i2c_io;         // Init MCP23008

    uint8_t canstat;
    uint8_t opmode, txstatus;
    volatile int isInt;
    //uint8_t tosend[8];
    uint8_t recSize, recData[8];

    //Rx
    uint8_t push;
    uint16_t msgID;

};


#endif // BUS_H_INCLUDED
